package com.cyf.wechat;

import com.cyf.app.network.bean.AppBusinessReq;
import com.cyf.app.network.bean.car.AppAdCarReq;
import com.cyf.pay.wxpay.service.WxpayService;
import com.cyf.wechat.network.bean.*;
import com.cyf.wechat.service.WechatApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by cage on 2016/9/4.
 */
@RestController
@Api("微信公众号")
@RequestMapping("api/wechat")
@Slf4j
public class PlatformHttpController {


    @Resource
    private WechatApiService wechatApiService;

    @Resource
    private WxpayService wxpayService;


    @ApiOperation(value = "登录注册")
    @PostMapping(value = "/login")
    public WechatRegRsp registe(@RequestBody LoginAppReq req) {
        return wechatApiService.login(req) ;
    }

    @ApiOperation(value = "添加车辆")
    @PostMapping(value = "/addCar")
    public WechatRegRsp addCar(@RequestBody AppAdCarReq req) {
        return wechatApiService.addCar(req);
    }

    @ApiOperation(value = "根据id获取车辆信息")
    @PostMapping(value = "/findAppCarById")
    public WechatRegRsp findAppCarById(@RequestBody AppCarReq req) {
        return wechatApiService.findAppCarById(req.getId(),req.getOpendId());
    }

    @ApiOperation(value = "修改车辆信息")
    @PostMapping(value = "/editCar")
    public WechatRegRsp editCar(@RequestBody AppAdCarReq req) {
        return wechatApiService.editCar(req);
    }


    @ApiOperation(value = "获取车辆列表信息")
    @PostMapping(value = "/findCarList")
    public WechatRegRsp findCarList(@RequestBody AppBusinessReq req) {
        return wechatApiService.findCarList(req);
    }

    @ApiOperation(value = "删除车辆信息")
    @PostMapping(value = "/deleteAppCar")
    public WechatRegRsp deleteAppCar(@RequestBody AppCarReq req) {
        return wechatApiService.deleteAppCar(req);
    }

    @ApiOperation(value = "获取用户信息")
    @PostMapping(value = "/findUserInfo")
    public WechatRegRsp findUserInfo(@RequestBody AppBusinessReq req) {
        return wechatApiService.findUserInfo(req);
    }



    @ApiOperation(value = "获取用户车辆在场信息")
    @GetMapping(value = "/findUserParkingInfo")
    public WechatRegRsp findUserParkingInfo(@RequestParam String openId) {
        return wechatApiService.findUserParkingInfo(openId);
    }

    @ApiOperation(value = "根据车牌查询获取车辆缴费信息")
    @GetMapping(value = "/findWechatGetFee")
    public WechatRegRsp findWechatGetFee(@RequestParam String openId,@RequestParam String plate) {
        return wechatApiService.findWechatGetFee(openId,plate);
    }

    @ApiOperation(value = "获取车主优惠券")
    @GetMapping(value = "/findUseCoupon")
    public WechatRegRsp findUseCoupon(@RequestParam String openId,@RequestParam String plate,@RequestParam Integer parkingId) {
        return wechatApiService.findUseCoupon(openId,plate,parkingId);
    }


    @ApiOperation(value="优惠券转赠")
    @GetMapping(value="/merchantTransfer")
    public WechatRegRsp merchantRecharge(@RequestParam String ids,@RequestParam String phone){
        return wechatApiService.merchantTransfer(ids,phone);
    }


    @ApiOperation(value="查询通行记录")
    @PostMapping(value="/inoutparking/query")
    public WechatRegRsp inOutParkingQuery(@RequestBody WechatInOutParkingReq req){
        return wechatApiService.inOutParkingQuery(req);
    }

    @ApiOperation("获取停车订单（开票列表）")
    @PostMapping(value = "/findStopParkingRecord")
    public WechatRegRsp findStopParkingRecord(@RequestBody InvoiceReq req){
        return wechatApiService.findStopParkingRecord(req);
    }

    @ApiOperation("获取开票历史（开票列表）")
    @PostMapping(value = "/findInvoiceHistory")
    public WechatRegRsp findInvoiceHistory(@RequestBody InvoiceReq req){
        return wechatApiService.findInvoiceHistory(req);
    }

    @ApiOperation("获取历史开票信息（发票）")
    @PostMapping(value = "/findUserInvoiceHistory")
    public WechatRegRsp findUserInvoiceHistory(@RequestBody AppBusinessReq req){
        return wechatApiService.findUserInvoiceHistory(req);
    }

    @ApiOperation("删除发票信息")
    @PostMapping(value = "/deleteUserInvoice")
    public WechatRegRsp deleteUserInvoice(@RequestBody AppBusinessReq req){
        return wechatApiService.deleteUserInvoice(req);
    }
    @ApiOperation("删除发票历史")
    @PostMapping(value = "/deletePiaotongInvoice")
    public WechatRegRsp deletePiaotongInvoice(@RequestBody DeletePiaotongInvoiceReq req){
        return wechatApiService.deletePiaotongInvoice(req.getPhone(),req.getOpenId(),req.getId());
    }


    @ApiOperation("月卡充值获取订单号")
    @PostMapping(value = "/recharge")
    public WechatRegRsp recharge(@RequestBody WechatCarRechargeReq req){
        return wechatApiService.recharge(req);
    }



    @ApiOperation(value = "获取路测待支付订单")
    @PostMapping(value = "/findRoadPayOrderList")
    public WechatRegRsp findRoadPayOrderList(@RequestParam String openId, @RequestParam(required = false) String phone,@RequestParam Integer type ) {
        return wechatApiService.findRoadPayOrderList(openId,phone,type);
    }

    @ApiOperation(value = "路测订单合并接口")
    @PostMapping(value = "/roadPayOrderMerge")
    public WechatRegRsp roadPayOrderMerge(@RequestParam String openId,@RequestParam String orderNos) {
        return wechatApiService.roadPayOrderMerge(openId,orderNos);
    }



    /*@ApiOperation(value = "获取")
    @PostMapping(value = "/wechatPaymentOrder")
    public WechatRegRsp wechatPaymentOrder(@RequestParam String openId,@RequestParam String orderNos) {
        return null;//wechatApiService.(openId,orderNos);
    }*/




}
